﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DigitalPlatform.Common.Mangaer
{
    public static class ActionManager<T>
    {
        public static Dictionary<string, Func<T>> Actions { get; private set; } = new Dictionary<string, Func<T>>();

        public static void Register(string key, Func<T> action)
        {
            if (!Actions.ContainsKey(key))
                Actions.Add(key, action); 
        }

        public static T ExecuteAction(string key)
        {
            if(Actions.ContainsKey(key))
                return Actions[key].Invoke();
            return default(T);

        }
    }
}
